import java.awt.Color;
import java.awt.Container;
import java.awt.Dimension;

import javax.swing.BoxLayout;
import javax.swing.JButton;
import javax.swing.JFrame;
import javax.swing.JLabel;
import javax.swing.JPanel;

/**
 * A simple two panel frame in a Y_AXIS layout, that can be changed on the fly, to display the current state (top)
 * and the HUD panel (bottom).
 * TOP panel - 780 x 510 pixels (widescreen)
 * BOTTOM (HUD) - 780 x 150 
 * @author Hobosapiens
 */

public class Display {
JFrame f;
JPanel statePanel, hudPanel, currState;
Container content;

	/**
	 * Constructor
	 */
	public Display(){
	    f = new JFrame("This is a test");
	    	
	    	f.setDefaultCloseOperation(JFrame.EXIT_ON_CLOSE);
	    content = f.getContentPane();
	    	content.setBackground(Color.white);
	    	content.setLayout(new BoxLayout(content, BoxLayout.Y_AXIS));
	    	
	    statePanel = new JPanel();
	    	statePanel.setLayout(new BoxLayout(statePanel, BoxLayout.Y_AXIS));
	    	statePanel.setMaximumSize(new Dimension(800,550));
	    hudPanel = new JPanel();
	    	hudPanel.setLayout(new BoxLayout(hudPanel, BoxLayout.X_AXIS));
	    	hudPanel.setMaximumSize(new Dimension(800,150));
	    	
	    f.setContentPane(content);
	    content.add(statePanel);
	    content.add(hudPanel);
	    
	    statePanel.add(new JLabel("statepanel"));
	    statePanel.setAlignmentX(1);
	    hudPanel.setBackground(Color.green);
	    hudPanel.setAlignmentX(1);
	    
	    
	}

	/**
	 * Build the JFrame
	 */
	public void start(){
		f.pack();
		f.setSize(new Dimension(800, 700));
		f.setVisible(true);
	}
	
	/**
	 * Swap out the JPanels being shown in the Display
	 * @param state JPanel
	 */
	public void changeState(JPanel state){	 
		currState = state;
		statePanel.removeAll();
		
	    statePanel.add(currState);
	    statePanel.revalidate();	
	    statePanel.repaint();

	}
	public State getState(){
		return (State) currState;
	}
	
	/**
	 * Adds hud
	 * @param hud JPanel 
	 */
	public void setHUD(JPanel hud){
		hudPanel.removeAll();
		hudPanel.add(hud);
		hudPanel.revalidate();
	}

	
}
